package guoanmaker.operator.business.controller;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.service.OperatorGuaranteeServiceInterface;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(ApiController.OPERATOR_FRIENDSHIPLINK_URL)
public class OperatorGuaranteeController {

	@Autowired
	private OperatorGuaranteeServiceInterface operatorGuaranteeServiceInterface;
	
	@ApiOperation(value = "查询商品保障须知", notes = "查询商品保障须知")
	@PostMapping(value = "getOperatorGuarantee")
	public AjaxJson getOperatorGuarantee(){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorGuaranteeServiceInterface.getOperatorGuarantee());
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(true).setStatus(250).setData("无数据");
		}
		return ajaxJson;
	}
	
	@Transactional
	@ApiOperation(value = "插入或者修改商品保障须知", notes = "插入或者修改商品保障须知")
	@PostMapping(value = "insertOrEdit")
	public AjaxJson insertOrEdit(String id,String guarantee,String userid){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorGuaranteeServiceInterface.insertOrEdit( id, guarantee, userid));
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(true).setStatus(200).setData("查询失败");
		}
		return ajaxJson;
	}
}
